#
# Module Name:
#    makefile
#
# Abstract:
#    Make file for kernel.
#
#  Author:
#    Josh Wu
#    rainyfeeling@hotmail.com
#    09.24.2008
# 
#  NOTE:
#    target: prerequisites
#       $@ means first word of target.
#       $< means first word of prerequisites.

BIN_FILES_PATH = ./bin/

ASM = gcc
ASM_FLAGS = -c
ENTRY_POINT = 0x30400
LINKER = ld
LINKER_FLAGS = --section-alignment 256 --file-alignment 256 -s -e c -Ttext $(ENTRY_POINT) --image-base 0x0


BIN_FILE = $(BIN_FILES_PATH)kernel.bin
OBJ_FILE = $(BIN_FILES_PATH)kernel.o
SOURCE_FILE = kernel.s

.PHONY : everything clean all

# Default starting position.
everything: $(BIN_FILE)

clean: 
	del .\bin\*.o
	del .\bin\*.bin
    
all: clean everything

$(OBJ_FILE): $(SOURCE_FILE)
	$(ASM) $(ASM_FLAGS) -o $@ $<
    
$(BIN_FILE): $(OBJ_FILE)
	$(LINKER) $(LINKER_FLAGS) -o $(BIN_FILE) $(OBJ_FILE)
	copy bin\kernel.bin c:\temp
    
    
    
    
    
